package com.whnk.web.controller.pm;

import java.util.List;

import com.whnk.pm.domain.ForbiddenStaff;
import com.whnk.pm.service.IForbiddenStaffService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.whnk.common.annotation.Log;
import com.whnk.common.enums.BusinessType;

import com.whnk.framework.web.base.BaseController;
import com.whnk.framework.web.page.TableDataInfo;
import com.whnk.common.base.AjaxResult;

/**
 * 禁用人员 信息操作处理
 * 
 * @author whwhnk
 * @date 2019-09-27
 */
@Controller
@RequestMapping("/pm/forbiddenStaff")
public class ForbiddenStaffController extends BaseController
{
    private String prefix = "pm/forbiddenStaff";
	
	@Autowired
	private IForbiddenStaffService forbiddenStaffService;
	
	@RequiresPermissions("pm:forbiddenStaff:view")
	@GetMapping()
	public String forbiddenStaff()
	{
	    return prefix + "/forbiddenStaff";
	}
	
	/**
	 * 查询禁用人员列表
	 */
	@RequiresPermissions("pm:forbiddenStaff:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(ForbiddenStaff forbiddenStaff)
	{
		startPage();
        List<ForbiddenStaff> list = forbiddenStaffService.selectForbiddenStaffList(forbiddenStaff);
		return getDataTable(list);
	}
	
	/**
	 * 新增禁用人员
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存禁用人员
	 */
	@RequiresPermissions("pm:forbiddenStaff:add")
	@Log(title = "禁用人员", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(ForbiddenStaff forbiddenStaff)
	{		
		return toAjax(forbiddenStaffService.insertForbiddenStaff(forbiddenStaff));
	}

	/**
	 * 修改禁用人员
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		ForbiddenStaff forbiddenStaff = forbiddenStaffService.selectForbiddenStaffById(id);
		mmap.put("forbiddenStaff", forbiddenStaff);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存禁用人员
	 */
	@RequiresPermissions("pm:forbiddenStaff:edit")
	@Log(title = "禁用人员", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(ForbiddenStaff forbiddenStaff)
	{		
		return toAjax(forbiddenStaffService.updateForbiddenStaff(forbiddenStaff));
	}
	
	/**
	 * 删除禁用人员
	 */
	@RequiresPermissions("pm:forbiddenStaff:remove")
	@Log(title = "禁用人员", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(forbiddenStaffService.deleteForbiddenStaffByIds(ids));
	}

	@RequiresPermissions("pm:forbiddenStaff:remove")
	@GetMapping( "/fileMove")
	@ResponseBody
	public void fileMove() {
		forbiddenStaffService.fileMove();
	}
}
